//
//  WFTableViewCell.swift
//  GZWeibo666
//
//  Created by 刘文锋 on 15/12/1.
//  Copyright © 2015年 itcast. All rights reserved.
//

import UIKit
//有数据显示的cell
class WFTableViewCell: UITableViewCell
{

  
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        prepareUI()
    }
    // MARK: - 准备UI
   func prepareUI()
   {
    /// 用户头像
    contentView.addSubview(iconView)
    /// 用户名称
    contentView.addSubview(nameLabel)
    /// 时间
    contentView.addSubview(timeLabel)
    //评论内容
    contentView.addSubview(commtenLabel)
      /// 会员等级图标
    contentView.addSubview(mbrankImageView)
    /// 认证类型图标
    contentView.addSubview(verifiedImageView)
    /// 顶部分割视图
    contentView.addSubview(separatorView)
    
    // 约束
    iconView.ff_AlignInner(type: ff_AlignType.TopLeft, referView: self, size: CGSize(width: 35, height: 35), offset: CGPoint(x: 8, y: 8))
    /// 用户名称
    /// 用户名称
    nameLabel.ff_AlignHorizontal(type: ff_AlignType.TopRight, referView: iconView, size: nil, offset: CGPoint(x: 8, y: 0))
    
    /// 会员图标
    mbrankImageView.ff_AlignHorizontal(type: ff_AlignType.CenterRight, referView: nameLabel, size: CGSize(width: 14, height: 14), offset: CGPoint(x: 8, y: 0))
    
    /// 时间
    timeLabel.ff_AlignHorizontal(type: ff_AlignType.BottomRight, referView: iconView, size: nil, offset: CGPoint(x: 8, y: 0))
    //评论内容
    commtenLabel.ff_AlignVertical(type: ff_AlignType.BottomLeft, referView: timeLabel, size: nil, offset: CGPoint(x: 0, y: 8))
    
    
    }
    // MARK: - 懒加载
    /// 用户头像
    private lazy var iconView: UIImageView = UIImageView(image: UIImage(named: "avatar"))
    
    /// 用户名称
    private lazy var nameLabel: UILabel = UILabel(color: UIColor.darkGrayColor(), fontSize: 13)
    
    /// 时间
    private lazy var timeLabel: UILabel = UILabel(color: UIColor.orangeColor(), fontSize: 8)
    //评论内容
    private lazy var commtenLabel: UILabel =
    {
        let label = UILabel(color: UIColor.blackColor(), fontSize: 15)
        label.sizeToFit()
        return label
    }()
    
    /// 会员等级图标
    private lazy var mbrankImageView: UIImageView = UIImageView()
    
    /// 认证类型图标
    private lazy var verifiedImageView:  UIImageView = UIImageView(image: UIImage(named: "avatar_vip"))
    
    /// 顶部分割视图
    private lazy var separatorView: UIView = {
        let view = UIView()
        // 背景
        view.backgroundColor = UIColor(white: 0.9, alpha: 1)
        return view
    }()
    
}
